package com.herui.iot.ui.view.ecg.bean;

import android.content.Context;
import android.graphics.Color;
import android.graphics.Paint;

import com.herui.sdyu_lib.utils.ScreenUtils;


/**
 * Created by Administrator on 2016/1/13.
 */
public class EcgStyle {

    // 背景
    protected static int BACKGROUND_COLOR = 0xffffffff;

    // ecg分格
    private static final int ECG_COLOR = Color.GREEN;
    private static final int ECG_FRAME_COLOR = Color.RED;
    private static final int ECG_Grid_COLOR = Color.RED;
    private static final int ECG_GGrid_COLOR = 0xffffbebe;
    private static final int ECG_TEXT_COLOR = Color.WHITE;

    public static final int ECG_FRAME_ARC_SIZE = 5;

    // 网格外间距 高度*ECG_FRAME_MARGIN_RATIO
    public static final float ECG_FRAME_MARGIN_RATIO = 0.02f;
    public static final float ECG_FRAME_BOARDER_WIDTH = 2;
    public static final float ECG_CELL_BOARDER_WIDTH = 1;

    // 文本 style
    public static final float ECG_TEXT_LEFT_MARGIN = 0.02f;
    public static final float ECG_TEXT_TOP_MARGIN = 0.02f;
    public static final float ECG_TEXT_SIZE = 15f;

    // 每个导联cell的个数
    public static final float ECG_VERTICAL_DEFAULT_CELL_NUM = 6;
    public static float ECG_VERTICAL_DEFAULT_CELL_MAX_PX;

    // 每个cell的持续时间
    public static final float ECG_CELL_DURATION = 0.2f;

    // 1s显示点的个数
    public static final int ECG_DISPLAY_FREQUENCY = 150;
    /**
     * Default display buffer size is 10 second
     */
    public static final int ECG_DISPLAY_BUFFER_SIZE =  10;

    public static Paint pFrame, pEcg, pCell, ppCell, pText, nomalPEcg;

    public static String[] ECGTEXT = {
            "I", "II", "III", "aVR", "aVL", "aVF", "V1", "V2",
            "V3", "V4", "V5", "V6",
    };

    private static void pFrameInit(){
        pFrame = new Paint();
        pFrame.setColor(ECG_FRAME_COLOR);
        pFrame.setStyle(Paint.Style.STROKE);
        pFrame.setStrokeWidth(ECG_FRAME_BOARDER_WIDTH);
    }

    private static void pCellInit(){
        pCell = new Paint();
        pCell.setColor(ECG_Grid_COLOR);
        pCell.setStyle(Paint.Style.STROKE);
        pCell.setStrokeWidth(ECG_CELL_BOARDER_WIDTH);

        ppCell = new Paint();
        ppCell.setColor(ECG_GGrid_COLOR);
        ppCell.setStyle(Paint.Style.STROKE);
        ppCell.setStrokeWidth(ECG_CELL_BOARDER_WIDTH);
    }

    private static void pEcgInit(){
        pEcg = new Paint();
        pEcg.setStyle(Paint.Style.STROKE);
        pEcg.setColor(ECG_COLOR);
        pEcg.setStrokeWidth(3);
    }

    private static void pTextInit(Context context){
        pText = new Paint();
        pText.setColor(ECG_TEXT_COLOR);
        pText.setTextSize(ScreenUtils.sp2px(context, 18));
    }

    private static void nomalPEcgInit(){
        nomalPEcg = new Paint();
        nomalPEcg.setColor(ECG_FRAME_COLOR);
        nomalPEcg.setStyle(Paint.Style.STROKE);
        nomalPEcg.setStrokeWidth(ECG_CELL_BOARDER_WIDTH);
    }

    public static void init(Context context) {
        pTextInit(context);
        pFrameInit();
        pEcgInit();
        pCellInit();

        ECG_VERTICAL_DEFAULT_CELL_MAX_PX = ScreenUtils.dip2px(context, 40);
    }

    public static void setpFrame(Paint pFrame) {
        EcgStyle.pFrame = pFrame;
    }

    public static void setpEcg(Paint pEcg) {
        EcgStyle.pEcg = pEcg;
    }

    public static void setNomalPEcg(Paint nomalPEcg) {
        EcgStyle.nomalPEcg = nomalPEcg;
    }

    public static void setpCell(Paint pCell) {
        EcgStyle.pCell = pCell;
    }

    public static void setpText(Paint pText) {
        EcgStyle.pText = pText;
    }

    public static void setBackgroundColor(int backgroundColor) {
        BACKGROUND_COLOR = backgroundColor;
    }

    public static int getBackgroundColor() {
        return BACKGROUND_COLOR;
    }
}
